<?php 
		$user=$session->read('User');
		$colleageid=$session->read("colleageid");
		$isflag = true;
?>
<div class="right_side_operate_area">

	<div class="right_side_title left">
		<h2>
			<?php 
					$colleagename=$session->read("colleagename");
					echo $html->link($colleagename,"/colleages/showcolleageinfo/".$colleageid);
			?>
		</h2>
		<div class="clear"></div>
	</div>
	
    <div class="right item_add_btn">
    <?php 
    	if($form->value('CgResearchcenter.id'))
    	{
    		$str_title=__("Edit",true);
		}
		else
		{
			$str_title=__("Add",true);
		}
		echo $html->link(__("Cancel",true).$str_title,"/colleages/researchcenters/");
    ?>
    </div>
    <div class="clear"></div>
    
</div>

<div class="right_side_scollbar">
    <div class="detail_info_panel">
    
    	<?php echo $form -> create('cgproduct', array('url' => '/colleages/editresearchcenter/','enctype'=>'multipart/form-data','type'=> 'post','onsubmit'=>'return checksave()') ); ?>
    	<div class="details_item_line">
			      <div class="details_item">
				      <div class="form_left_title left">中心名称：</div>
				      <div class="form_right_e_input left"><?php echo $form->text('CgResearchcenter.name');?></div>
				       <div id='namemessage' style='display:none;' class="error_message">请填写中心名称</div>
			      </div>
		</div>
		
		<div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left">成立时间：</div>
			    <div class="form_right_e_input form_date_picker left">
			    	<?php echo $form->text('CgResearchcenter.establish_time',array("maxlength"=>"10","style"=>"width:130px","onfocus"=>"WdatePicker()"));?>
			    </div>
			    <div id='timemessage' style='display:none;' class="error_message">请选择成立时间</div>
			</div>
	   </div>
	   
	   <div class="details_item_line">
		      <div class="details_item">
			      <div class="form_left_title left">中心介绍：</div>
			      <div class="form_right_e_input left"><?php echo $form->textarea('CgResearchcenter.description',array('class' => 'form_textarea'));?></div>
		      	  <div id='descriptionmessage' style='display:none;' class="error_message">请填写中心介绍</div>
		      </div>
		</div>
		
		 <!--附件块 开始-->
       	<div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">电子材料：</div>
                <div class="form_right_input left">
                	
                	<?php if($attachments){?>
                	<div class="file_category_list">
		        		<div id="filelist0" class="file_lists">
		        			<ul class="file_attach">
			                	<?php
					                	$dan="'";
					                	foreach($attachments as $attachment) 
					                	{
												echo "<li>";
												echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
												echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
												if($isflag)
												{
													echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
												}
												echo "</li>";
										}
			                	?>
			                </ul>
		                </div>
		            </div>
		            <?php }?>
		            
                	<div id="add1" class="left text_box"> 
						<div class="file_add_box">
							<input type="file" name="upload[]" />
						</div>
					</div>
					
	        		<div class="clear"></div>
	        		
					<div id="add2" class="left filelist"></div>
					<div class="left clear">
						<div class="left add_sub_file_btn">
							<span onclick="add()" href="#"><?php echo $html->image('list-add.png')?></span>&nbsp;
							<span onclick="remove()" href="#"><?php echo $html->image('list-remove.png')?></span>
						</div>
					</div>
				</div>
					
            </div>
        </div>
        <!--附件块 结束-->
        
        <div class="details_item_line">
			<div class="details_item">
					<div class="form_left_title left"></div>
			        <div class="form_add_submit left">
			        	<?php echo $form->submit(__('Save',true), array("id"=>"addactive","name"=>"submit","class"=>"buttom","div"=>false));  ?>
			            <?php echo $form->hidden('CgResearchcenter.colleage_id',array("value"=>$colleageid)) ;?>
			        	<?php echo $form->hidden('CgResearchcenter.id') ?>
			        </div>
			</div>
	  </div>
		
    </div>
</div>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
function checksave()
{
	 if($("#CgResearchcenterName").val().trim() == '')
	 {
			$("#namemessage").css('display','block');
			return false;
	  }
	  else
	  {
		 	 $("#namemessage").css('display','none');
	  }
	
	 if($("#CgResearchcenterEstablishTime").val().trim() == '')
	 {
		 $("#timemessage").css('display','block');
		return false;
	 }
	 else
	 {
		 $("#timemessage").css('display','none');
	 } 	  

	 if($("#CgResearchcenterDescription").val().trim() == '')
	 {
		 $("#descriptionmessage").css('display','block');
		return false;
	 }
	 else
	 {
		 $("#descriptionmessage").css('display','none');
	 } 	  
}  
</script>